﻿<%@ WebHandler Language="C#" Class="ExzamHandler" %>

using System;
using System.Web;
using System.Collections;

public class ExzamHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string action = context.Request["action"];

        IExzamEdit exzamEdit = new ExzamEdit();
        IExzamSearch exzamSearch = new ExzamSearch();
        string data_back = "";
        switch (action)
        {
            case "finalEdit":
                //exzamEdit.finalEdit();
                break;

            case "addExzam":
                Hashtable ht = new Hashtable();
                ht.Add("courseid", context.Request["courseid"]);
                ht.Add("exzamname", context.Request["exzamname"]);
                ht.Add("starttime", context.Request["starttime"]);
                ht.Add("endtime", context.Request["endtime"]);
                ht.Add("exzamplace", context.Request["exzamplace"]);
                ht.Add("exzamtype", context.Request["exzamtype"]);
                exzamEdit.singleAdd(ht);
                break;
            case "getExzamByCourseTech":
                string courseid = context.Request["courseid"];
                string techid = context.Request["techid"];
                data_back = exzamSearch.getExzamByCourseTech(courseid, techid);
                break;
            case "getExzamByStdTerm":
                string stdid = context.Request["stdid"];
                string yterm = context.Request["yterm"];
                data_back = exzamSearch.getExzamByStdTerm(stdid, yterm);

                break;
            case "getExzamByTechTerm":
                techid = context.Request["techid"];
                yterm = context.Request["yterm"];
                data_back = exzamSearch.getExzamByTechTerm(techid, yterm);

                break;
            case "singleExzamEdit":
                string exzamid = context.Request["exzamid"];
                string name = context.Request["name"];
                string place = context.Request["place"];
                string starttime = context.Request["starttime"];
                string endtime = context.Request["endtime"];
                string typeid = context.Request["typeid"];
                string exzamweight = context.Request["exzamweight"];
                ht = new Hashtable();
                ht.Add("exzamid", exzamid);
                ht.Add("name", name);
                ht.Add("place", place);
                ht.Add("starttime", starttime);
                ht.Add("endtime", endtime);
                ht.Add("typeid", typeid);
                ht.Add("exzamweight", exzamweight);
                exzamEdit.singleEdit(ht);
                break;
            default:
                break;
        }
        context.Response.ContentType = "text/plain";
        context.Response.Write(data_back);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}